<?php

use yii\db\Migration;
use yii\db\Schema;
/**
 * Class m181023_013549_CREATE_DB_COMMON
 */
class m181023_013549_CREATE_DB_COMMON extends Migration
{
    /**
     * {@inheritdoc}
     */
    public function safeUp()
    {

        $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';


        // 城市三字码
        $this->createTable('city_code', [
            "id" =>             Schema::TYPE_PK,
            "code" =>     Schema::TYPE_STRING.   "(10) NOT NULL COMMENT '城市三字码'",
            "zh_name" =>     Schema::TYPE_STRING.   "(32)  NULL  COMMENT '城市中文名'",
            "en_name" =>        Schema::TYPE_STRING. "(64)  NULL COMMENT '城市英文名'",
    
        ], $tableOptions);

         // 酒店集团
        $this->createTable('hotel_brand', [
            "id" =>             Schema::TYPE_PK,
            "en_name" =>        Schema::TYPE_STRING. "(64)  NULL COMMENT '品牌英文名'",
            "zh_name" =>     Schema::TYPE_STRING.   "(32)  NULL  COMMENT '品牌中文名'",
        ], $tableOptions);

        $this->createIndex('city_code','city_code',['code'],true);

    }

    /**
     * {@inheritdoc}
     */
    public function safeDown()
    {
        echo "m181023_013549_CREATE_DB_COMMON cannot be reverted.\n";

        return false;
    }

    /*
    // Use up()/down() to run migration code without a transaction.
    public function up()
    {

    }

    public function down()
    {
        echo "m181023_013549_CREATE_DB_COMMON cannot be reverted.\n";

        return false;
    }
    */
}
